{% extends "shuup/admin/base.jinja" %}
{% from "shuup/admin/macros/general.jinja" import content_with_sidebar, content_block %}
{% from "shuup/admin/macros/multilanguage.jinja" import render_monolingual_fields %}

{% block title %}{% trans %}Reports{% endtrans %}{% endblock %}

{% block body_class %}shuup-details{% endblock %}
{% block content %}
    <div class="container-fuid">
        {% if form %}
            {% call content_block(_("Reports"), "fa-info-circle") %}
                <form method="post" id="service_provider_form">
                    {% csrf_token %}
                    {{ render_monolingual_fields(form, field_names="report") }}
                    <div{% if result %} class="collapse"{% endif %} id="collapse">
                        {{ render_monolingual_fields(form, exclude="report") }}
                        {% if current_report and current_report.get_description() %}
                        <div class="form-group">
                            <div class="control-label">
                                Report Description
                            </div>
                            <div style="margin-top: 10px;">
                                {{ current_report.get_description() }}
                            </div>
                        </div>
                        {% endif %}
                    </div>
                    {% if result %}
                    <div class="row">
                        <div class="col-md-6">
                        <button class="btn btn-primary btn-block" type="button" data-target="#collapse" data-toggle="collapse" aria-expanded="false" aria-controls="collapse">{% trans %}Toggle Filters{% endtrans %}</button>
                        </div>
                        <div class="col-md-6">
                            <button type="submit" class="btn btn-primary btn-block">{% trans %}Get Report{% endtrans %}</button>
                        </div>
                    </div>
                    {% else %}
                        <button type="submit" class="btn btn-primary btn-block">{% trans %}Get Report{% endtrans %}</button>
                    {% endif %}
                </form>
            {% endcall %}
            {% if result %}
                <div class="content-block">{{ result }}</div>
            {% endif %}
        {% else %}
            <div class="content-block">{% trans %}No reports available{% endtrans %}</div>
        {% endif %}
    </div>
{% endblock %}

{% block extra_js %}
    {{ super() }}
    <script>
        $(function () {
            $("#id_report").on("change", function() {
                location.href = "{{ url('shuup_admin:reports.list') }}?report=" + $(this).val();
            });
        });
    </script>
{% endblock %}
